<?php session_start(); ?>
<?php include "libfunc.php";?>
<?php if (!empty($_SESSION['admUser']) && !empty($_SESSION['admPass'])) { ?>

<html>
 <head>
  <title>.: Admin Room ClothingCorp :.</title>
  <link href="admInc/cssMainStyle.css" type="text/css" rel="stylesheet">
  <link href="admInc/cssTableStyle.css" type="text/css" rel="stylesheet">
  <link href="admInc/cssAdditionStyle.css" type="text/css" rel="stylesheet">
  <link href="admInc/cssTableNavigation.css" type="text/css" rel="stylesheet">
 </head>
 <body class="fix">
  <div id="wrapper">
   <div id="header">
    <div class="titleHeader">
     <img src="image/logo2.png" border="0">
	</div><!-- titleHeader //-->
	<div class="subTitleHeader">
	 - Website Administrator Control Panel -
	</div><!-- subTitleHeader //-->
   </div><!-- header //-->
   <div id="mainContent">
    <div id="leftColumn">
	 <div class="navigation">
	  <table border="0" width="100%" bgcolor="white">
	  <tr>
	    <td class="headerTable" align="center"><b>Admin Page</b></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="adminLayout.php"> Halaman Utama</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="newInformation.php"> Informasi Terkini</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="LogOut.php" onClick="return confirm('Apakah Anda benar-benar akan keluar dari halaman Admin ?')"> Keluar</a></td>
	  </tr>
	  <tr>
	    <td align="center" height="2"></td>
	  </tr>
	  <tr>
	    <td class="headerTable" align="center"><b>Data Penerbit</b></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="tambah_penerbit.php"> Tambah Penerbit</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="view_penerbit.php"> View Penerbit</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="pencarian_penerbit.php"> Pencarian Penerbit</a></td>
	  </tr>
      <tr>
	    <td></td>
	  </tr>
      <tr>
	    <td></td>
	  </tr>
	  <tr>
	    <td class="headerTable" align="center"><b>Data Kategori</b></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="tambah_kategori.php"> Tambah Kategori</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="view_kategori.php"> View Kategori</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="pencarian_kategori.php"> Pencarian Kategori</a></td>
	  </tr>
      <tr>
	    <td></td>
	  </tr>
      <tr>
	    <td></td>
	  </tr>
	  <tr>
	    <td class="headerTable" align="center"><b>Data Member</b></td>
	  </tr>
	  <tr>
	    <td class="current"><img src="image/tag_blue.png"><a href="tambah_member.php"> Tambah Member</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="view_member.php"> View Member</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="pencarian_member.php"> Pencarian Member</a></td>
	  </tr>
      <tr>
	    <td></td>
	  </tr>
      <tr>
	    <td></td>
	  </tr>
	  <tr>
	    <td class="headerTable" align="center"><b>Data Buku</b></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="tambah_buku.php"> Tambah Buku</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="view_buku.php"> View Buku</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="pencarian_buku.php"> Pencarian Buku</a></td>
	  </tr>
      <tr>
	    <td></td>
	  </tr>
	  <tr>
	    <td></td>
	  </tr>
	  <tr>
	    <td class="headerTable" align="center"><b>Data Request Buku</b></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="view_request.php"> View Request</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="pencarian_request.php"> Pencarian Request</a></td>
	  </tr>
	  <tr>
		<td></td>
	  </tr>
	  <tr>
	    <td></td>
	  </tr>
	  <tr>
	    <td class="headerTable" align="center"><b>Data Pesanan</b></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="view_pesanan.php"> View Pesanan</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="pencarian_pesanan.php"> Pencarian Pesanan</a></td>
	  </tr>
      <tr>
	    <td></td>
	  </tr>
	</table>
	 </div><!-- navigation //-->
	</div><!-- leftColumn //-->
	<div id="rightColumn">
	 <div class="content">
       <?php
		//------pengambilan data dari form----------
		$nm = $_POST['nama'];
		$mail = $_POST['email'];
		$telpon = $_POST['tlp'];
		$almt = $_POST['alamat'];
		$kota = $_POST['kota'];
		$psw = MD5($_POST['psw']);
		$id_member = substr(MD5($_POST['email']),0,5);
		//-------end of pengambilan data dari form
		
		// pengecekan email yang sama
		$cekEmail = cekEmailSama($mail);
		if ($cekEmail == 1) {?>
		  <div id="keterangan">
		   <fieldset>
		    <legend>Keterangan</legend>
			 Data Member tidak dapat disimpan dikarenakan terdapat email duplikat!!!<br><br><br>
             <input type="button" onClick="javascript:history.back()" value="Kembali">
		   </fieldset>
		  </div>
          </div>
		  <?php 
		  exit();
		}
		// ------------- end of pengecekan email yang sama
		
		
		$link = koneksi_db();
		$sql  = "insert into dtmember values('$id_member','$nm','$mail','$telpon','$almt','$kota','$psw')";
		$res  = mysql_query($sql,$link);
		if ($res){
	   ?>
		  <div id="keterangan">
		   <fieldset>
		    <legend>Keterangan</legend>
			 Data Member <?php echo $nama; ?> telah tersimpan di Database.<br><br>
             Klik <a href="tambah_member.php" onClick="javascript:history.back()"><img src="image/house_go.png"></a>untuk menambah Member baru lagi.
           </fieldset>
		  </div>
	   <?php
		 }else {  // --- jika data di $res kosong
	   ?>
		  <div id="keterangan">
		   <fieldset>
		    <legend>Keterangan</legend>
			 Maaf Terjadi Kesalahan dalam menyimpan Data Member <?php echo $nama; ?>.<br><br>
             Silakan Hubungi Admin Program Ini.<br><br>
             Bila Anda Ingin mengulang kembali klik Tombol ini.<br><br>
             <input type="button" onClick="javascript:history.back()" value="Kembali">
		   </fieldset>
		  </div>
	   <?php
		 } // end of else
	  ?>
		
	</div><!-- rightColumn //-->
   </div><!-- mainContent //-->
  </div><!-- wrapper //-->
 </body>
</html>
<?php
}else{
  echo "<script language='javascript'>alert('Silakan Sign In Terlebih Dahulu')</script>";
  echo "<script language='javascript'>window.location = '../admin/'</script>";
}